package com.accp.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.accp.dao.CommentsDao;
import com.accp.dao.HotevensDao;
import com.accp.entity.Comments;
import com.accp.entity.Hotevents;
import com.accp.service.CommentsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@Service
public class CommentsServiceImpl implements CommentsService {
	
	@Autowired
	private CommentsDao comdao;
	
	@Autowired
	private HotevensDao hotdao;
	
	@Override
	public List<Comments> findAll(int hotEventsId) {
		// TODO Auto-generated method stub
		QueryWrapper<Comments> qu = new QueryWrapper<Comments>();
		qu.eq("hotEventsId",hotEventsId);
		return comdao.selectList(qu);
	}

	@Override
	@Transactional
	public int addComments(Comments comments) {
		// TODO Auto-generated method stub
		comdao.insert(comments);
		Hotevents hot = hotdao.selectById(comments.getHotEventsId());
		hot.setSearchSum(hot.getSearchSum()+1);
		return hotdao.updateById(hot);
	}

}
